set -e

source ./constants.sh

if [ ! -d ${HOST_ENV_DIR}/node-v22.14.0-linux-x64 ]; then
    echo "Please download node-v22.14.0-linux-x64 to ${HOST_ENV_DIR} first."
    exit 1
fi

if [ ! ${HOST_ENV_DIR}/Miniconda3-py311_25.1.1-2-Linux-x86_64.sh ]; then
    echo "Please download Miniconda3-py311_25.1.1-2-Linux-x86_64.sh to ${HOST_ENV_DIR} first."
    exit 1
fi

docker run -it \
    -p 5173:5173 \
    -p 8080:8080 \
    --name ${CONTAINER_NAME} \
    -v ${HOST_ENV_DIR}:${CONTAINER_DIR} \
    -v ${HOST_ENV_DIR}/node-v22.14.0-linux-x64:${CONTAINER_DIR}/node-v22.14.0-linux-x64 \
    -v ${HOST_ENV_DIR}/Miniconda3-py311_25.1.1-2-Linux-x86_64.sh:${CONTAINER_DIR}/Miniconda3-py311_25.1.1-2-Linux-x86_64.sh \
    -v ${OPENWEBUI_SRC_DIR}:${CONTAINER_DIR}/open-webui \
    ${BASE_IMAGE_NAME} /bin/bash
